package com.liuyingxing.javaSpringCloudWeb.modules.account.controller;


import com.liuyingxing.entity.account.User;
import com.liuyingxing.entity.common.Result;
import com.liuyingxing.javaSpringCloudWeb.modules.account.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by IntelliJ IDEA.
 * @File UserController.java
 * @Auth liuxing
 * @Date 2021/8/22 10:36
 * @Email liuxing997@foxmail.com
 */
@RestController
@RequestMapping("/api/web")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 127.0.0.1:8763/api/web/login ---- post
     */
    @PostMapping(value = "/login", consumes = "application/json")
    public Result<User> login(HttpServletRequest request,
                              @RequestBody User user) {
        return userService.login(request, user);
    }

    /**
     * 127.0.0.1:8763/api/web/user ---- post
     */
    @PostMapping(value = "/user", consumes = "application/json")
    public Result<User> insertUser(HttpServletRequest request,
                                   @RequestBody User user) {
        return userService.insertUser(request, user);
    }

    /**
     * 127.0.0.1:8763/api/web/logout ---- post
     */
    @GetMapping("/logout")
    public void logout(HttpServletRequest request) {
        userService.logout(request);
    }
}
